package com.liang.sendpsy.controller;

import com.liang.sendpsy.service.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
public class SendMainController {
    @Autowired
    MailService mailService;
    @Value("${spring.mail.username}")
    private String username;
    @Value("${touser}")
    private String toUser;
    @GetMapping("/send")
    public String send(){
        try {
            mailService.sendMail(username,toUser);

        } catch (Exception e) {
            log.error("发送失败，{}",e);
            e.printStackTrace();
        }
        return "ok";
    }
}
